package com.suyang.syt.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.suyang.syt.dao.interfaces.WeixinGroupDao;
import com.suyang.syt.model.WeixinGroup;

@Repository
public class WeixinGroupImpl extends BaseDaoImpl<WeixinGroup> implements WeixinGroupDao {

	@Override
	public void clear() {
		String hql = " delete from WeixinGroup ";
		this.executeByHql(hql);
	}

	@Override
	public void deletes(String ids) {
		String hql = " delete from WeixinGroup where id in(" + ids + ")";
		this.executeByHql(hql);
	}

	@Override
	public void updateGroup(int id, String name) {
		String hql = " update WeixinGroup set name=? where id=? ";
		this.executeByHql(hql, new Object[] { name, id });
	}

	@Override
	public WeixinGroup loadByid(int groupid) {
		String hql = " from WeixinGroup where id=? ";
		List<WeixinGroup> list = this.list(hql, groupid);
		if (list != null && list.size() == 1) {
			return list.get(0);
		}
		return null;
	}

}
